from APITest.online_course_2018.Day4.woniusales import WoniuSales
import random


class AddCustomerTest:
    def __init__(self):
        self.ws = WoniuSales()

    # 测试用例: 所有参数都正确
    def all_valid(self):
        name = 'woniu01'
        ran_num = random.randint(10000000, 99999999)
        self.phone = '181' + str(ran_num)
        sex = '男'
        date = '2015-05-12'
        creditkids = 10
        creditcloth = 0
        exp_result = 'add-successful'
        exp_status_code = '200'
        self.ws.add_customer_test(name, self.phone, sex, date, creditkids, creditcloth, exp_result, exp_status_code)

    # 测试用例:电话号码重复
    def num_dup(self):
        name = 'woniu02'
        sex = '女'
        date = '2016-05-12'
        creditkids = 11
        creditcloth = 10
        exp_result = 'already-added'
        exp_status_code = '200'
        self.ws.add_customer_test(name, self.phone, sex, date, creditkids, creditcloth, exp_result, exp_status_code)

    # 测试用例:姓名为空
    def name_empety(self):
        name = ''
        ran_num = random.randint(10000000, 99999999)
        phone = '181' + str(ran_num)
        sex = '男'
        date = '2015-05-12'
        creditkids = 10
        creditcloth = 0
        exp_result = 'add-failed'
        exp_status_code = '200'
        self.ws.add_customer_test(name, phone, sex, date, creditkids, creditcloth, exp_result, exp_status_code)


if __name__ == '__main__':
    act = AddCustomerTest()
    act.all_valid()
    act.num_dup()
    act.name_empety()
